﻿using System;

namespace Domain.Engine.Tests
{
  public class Piece
  {
    private readonly PieceColor _color;
    private readonly PieceType _type;

    private Piece(PieceType type, PieceColor color)
    {
      _type = type;
      _color = color;
    }

    private string Type
    {
      get
      {
        string typeChar;
        switch (_type)
        {
          case PieceType.None:
            typeChar = ".";
            break;
          case PieceType.Pawn:
            typeChar = "P";
            break;
          case PieceType.Rook:
            typeChar = "R";
            break;
          case PieceType.Knight:
            typeChar = "N";
            break;
          case PieceType.Bishop:
            typeChar = "B";
            break;
          case PieceType.Queen:
            typeChar = "Q";
            break;
          case PieceType.King:
            typeChar = "K";
            break;
          default:
            throw new ArgumentOutOfRangeException();
        }
        return typeChar;
      }
    }

    private string Color
    {
      get
      {
        string colorChar;
        switch (_color)
        {
          case PieceColor.None:
            colorChar = ".";
            break;
          case PieceColor.White:
            colorChar = "W";
            break;
          case PieceColor.Black:
            colorChar = "B";
            break;
          default:
            throw new ArgumentOutOfRangeException();
        }
        return colorChar;
      }
    }

    public static Piece Empty()
    {
      return new Piece(PieceType.None, PieceColor.None);
    }

    public static Piece Create(PieceType pieceType, PieceColor pieceColor)
    {
      return new Piece(pieceType, pieceColor);
    }

    public override string ToString()
    {
      return Color + Type;
    }
  }
}